package com.zdb.demo.spark.sql;

import org.apache.spark.SparkConf;
import org.apache.spark.sql.SparkSession;

public class SqlDemo {

    public static void main(String[] args) {
        SparkConf conf = new SparkConf().setMaster("local[4]").setAppName("test");
        SparkSession session = SparkSession.builder().config(conf).getOrCreate();
        // 关闭代码生成，降低物理执行计划的复杂度
        session.conf().set("spark.sql.codegen.wholeStage", "false");
        session.read().json("spark/files/student.json").createOrReplaceTempView("student");

        session.sql("select name from student where age > 18").show();
    }
}
